package tech.aistar.service.impl.authordis;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tech.aistar.entity.authordis.NoteAuthor;
import tech.aistar.entity.authordis.Notes;
import tech.aistar.mapper.authordis.ITravelerInfoDisMapper;
import tech.aistar.service.authordis.ITravelerInfoDisService;

import java.util.List;

/**
 * Created by lenovo on 2019/10/11.
 */
@Service
@Transactional
public class TravelerInfoDisServiceImpl implements ITravelerInfoDisService {

    @Autowired
    private ITravelerInfoDisMapper travelerInfoDisMapper;


    @Override
    public PageInfo<Notes> findNotesByAuthorId(Integer id, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);

        List<Notes> notesList = travelerInfoDisMapper.findNotesByAuthorId(id);

        PageInfo<Notes> pageInfo = new PageInfo<>(notesList);

        return pageInfo;
    }

    @Override
    public NoteAuthor findAuthorByUserId(Integer id) {
        NoteAuthor noteAuthor = travelerInfoDisMapper.findAuthorByUserId(id);
        return noteAuthor;
    }

    @Override
    public void updateNoteById(Integer id) {
        travelerInfoDisMapper.updateNoteById(id);
    }
}
